﻿
@{
    Layout = null;
}


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>
        .layui-form-label{
            width:120px;
        }
    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">


            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>三车间后道流程卡</legend>
            </fieldset>

            <form class="layui-form" action="" lay-filter="example">
                <input type="hidden" name="ID" value="0" />
                <input type="hidden" name="GoodsID" value="" id="GoodsID" />
                <input type="hidden" name="SourceGoodsID" value="" id="SourceGoodsID" />
                <input type="hidden" name="BillIndex4ID" value="" id="BillIndex4ID" />
                <div class="layui-form-item">
                    <div class="layui-input-block" style="display:none;">
                        <button class="layui-btn layui-btn-normal" onclick="ShowSelectGoods('g')" type="button">选择产成品</button>
                    </div>
                </div>
                <div class="layui-form-item" style="display:none;">
                    <div class="layui-inline">
                        <label class="layui-form-label">产成品名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="GoodsName" lay-verify="" autocomplete="off" class="layui-input" id="GoodsName" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-inline" style="display:none;">
                        <label class="layui-form-label">产成品编号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="GoodsCode"  autocomplete="off" class="layui-input" id="GoodsCode" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">产成品型号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="GoodsModel" lay-verify="" autocomplete="off" class="layui-input" id="GoodsModel" disabled="disabled">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" onclick="ShowSelectBillIndex()" type="button">选择头道流程卡</button>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">头道产品名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="SourceGoodsName" lay-verify="required" autocomplete="off" class="layui-input" id="SourceGoodsName" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-inline" style="display:none;">
                        <label class="layui-form-label">头道产品编号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="SourceGoodsCode" autocomplete="off" class="layui-input" id="SourceGoodsCode" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">头道产品型号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="SourceGoodsModel" lay-verify="required" autocomplete="off" class="layui-input" id="SourceGoodsModel" disabled="disabled">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">卡号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Code" lay-verify="required" autocomplete="off" class="layui-input" id="Code">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">投产数量</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Qty" lay-verify="required|number" autocomplete="off" class="layui-input" id="Qty">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">客户编号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="KeHuCode" lay-verify="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">合同号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="HeTongHao" autocomplete="off" class="layui-input" id="HeTongHao">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">打字名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="NewName" autocomplete="off" class="layui-input" id="NewName">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">批次号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Number" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">质量等级</label>
                        <div class="layui-input-inline">
                            <select name="DengJi" lay-search id="DengJI">
                                <option value="">请选择</option>
                                @Html.Raw(ViewBag.DengJi)
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">封装外形</label>
                        <div class="layui-input-inline">
                            <input type="text" name="WaiXing" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">模版</label>
                        <div class="layui-input-inline">
                            <select name="MoBanID" lay-search id="MoBanID">
                                <option value="0">无</option>
                                @Html.Raw(ViewBag.MoBan)
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text" style="display:none;">
                    <label class="layui-form-label">说明</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" class="layui-textarea" name="Remark"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="~/layui/layui.js"></script>
    <script src="~/scripts/jquery-1.4.4.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
        layui.use(['form', 'layedit', 'laydate', 'jquery'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , $ = layui.jquery
            //日期

            laydate.render({
                elem: '#TouDate'
                , trigger: 'click'
            });
            laydate.render({
                elem: '#LingDate'
                , trigger: 'click'
            });
            //监听提交
            form.on('submit(demo1)', function (data) {
                $.ajax({
                    url: '@Url.Action("IndexEditAsync","Bill8")',
                    type: 'post',
                    dataType: 'json',
                    data: data.field,
                    success: function (data) {
                        console.log(data);
                        //Info,Success,Warning,Error
                        var type = data.Type;
                        if (type == 1) {
                            layer.msg(data.Content, { icon: 6, time: 2000 },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                });

                        } else {
                            layer.alert(data.Content, { icon: 5 });
                        }
                    }
                });
                //layer.alert(JSON.stringify(data.field), {
                //    title: '最终的提交信息'
                //})
                return false;
            });
            @*$(document).on('change', "#GoodsCode", function () {
                $.ajax({
                    url: '@Url.Action("GoodsInfoAsync", "Procedure")',
                    type: 'post',
                    dataType: 'json',
                    data: { GoodsCode: $('#GoodsCode').val() },
                    success: function (data) {
                        console.log(data);
                        //Info,Success,Warning,Error
                        var type = data.Type;
                        if (type == 1 && data.Data.ID > 0) {
                            $('#GoodsID').val(data.Data.ID);
                            $('#GoodsName').val(data.Data.Name);

                        } else {
                            layer.alert('没找到此编码的零件', { icon: 5 });
                            $('#GoodsID').val('0');
                            $('#GoodsName').val('');
                        }
                    }
                });
            });*@
            //表单初始赋值
            form.val('example', {
                "ID": "@ViewBag.model.ID"
                    , "GoodsID": "@ViewBag.model.GoodsID"
                    , "GoodsCode": "@ViewBag.model.GoodsCode"
                    , "GoodsName": "@ViewBag.model.GoodsName"
                    , "GoodsModel": "@ViewBag.model.GoodsModel"
                    , "SourceGoodsID": "@ViewBag.model.SourceGoodsID"
                    , "SourceGoodsCode": "@ViewBag.model.SourceGoodsCode"
                    , "SourceGoodsName": "@ViewBag.model.SourceGoodsName"
                    , "SourceGoodsModel": "@ViewBag.model.SourceGoodsModel"
                    , "Code": "@ViewBag.model.Code"
                    , "Qty": "@ViewBag.model.Qty"
                    , "HeTongHao": "@ViewBag.model.HeTongHao"
                    , "KeHuCode": "@ViewBag.model.KeHuCode"
                    , "Number": "@ViewBag.model.Number"
                    , "WaiXing": "@ViewBag.model.WaiXing"
                    , "DengJi": "@ViewBag.model.DengJi"
                    , "BillIndex4ID": "@ViewBag.model.BillIndex4ID"
            })


        });
        function ShowSelectGoods(back) {
            var index = layer.open({
                title: '选择产品',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: false,
                area: ['800px', '400px'],
                content: '@Url.Action("GoodsSelect", "BasicInfo")' + '?Back=' + back + '&TypeID=3&BillNameID=8',
            });
            layer.full(index);
            return false;
        }
        function ShowSelectBillIndex(back) {
            var index = layer.open({
                title: '选择流程卡',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: false,
                area: ['800px', '400px'],
                content: '@Url.Action("BillIndexSelect", "BasicInfo")' + '?Back=' + back + '&BillNameID=4',
            });
            layer.full(index);
            return false;
        }
        function selectgoods(id, code, name, model, back) {
            if (back == 'g') {
                $('#GoodsID').val(id);
                $('#GoodsCode').val(code);
                $('#GoodsName').val(name);
                $('#GoodsModel').val(model);
            }
            if (back == 'sg') {
                $('#SourceGoodsID').val(id);
                $('#SourceGoodsCode').val(code);
                $('#SourceGoodsName').val(name);
                $('#SourceGoodsModel').val(model);
            }
        }
        function selectbillindex(code, goodsid, goodscode, goodsname, goodsmodel, qty, zhengbei, dengji, waixing, number, id, houcount) {
            $('#GoodsID').val(goodsid);
            $('#GoodsCode').val(goodscode);
            $('#GoodsName').val(goodsname);
            $('#GoodsModel').val(goodsmodel);
            $('#SourceGoodsID').val(goodsid);
            $('#SourceGoodsCode').val(goodscode);
            $('#SourceGoodsName').val(goodsname);
            $('#SourceGoodsModel').val(goodsmodel);
            $('#TouQty').val(qty);
            houcount = parseInt(houcount) + 1;
            $('#Code').val(code + '-' + houcount);
            $('#BillIndex4ID').val(id);
        }
    </script>

</body>
</html>